<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理员登录 - SparkShop</title>
    <link rel="stylesheet" href="{__CSS__}/element_ui.css"/>
    <link rel="stylesheet" href="{__CSS__}/style.css"/>
    <script src="{__JS__}/vue2.js"></script>
    <script src="{__JS__}/element_ui.js"></script>
    <script src="{__JS__}/axios.min.js"></script>
    <script src="{__JS__}/request.js"></script>
    <script>if(window.top !== window.self){ window.top.location = window.location;}</script>
</head>
<body>
<div id="app">
    <div class="login-container">
        <div class="particles-bg"></div>
        <div class="login-box">
            <div class="login-left">
                <div class="brand-section">
                    <div class="logo-container">
                        <div class="logo-text">SparkShop</div>
                        <div class="logo-subtitle">现代化电商管理系统</div>
                    </div>
                    <div class="feature-grid">
                        <div class="feature-item">
                            <div class="feature-icon">🚀</div>
                            <div class="feature-text">高效稳定</div>
                        </div>
                        <div class="feature-item">
                            <div class="feature-icon">🎨</div>
                            <div class="feature-text">美观易用</div>
                        </div>
                        <div class="feature-item">
                            <div class="feature-icon">⚡</div>
                            <div class="feature-text">快速开发</div>
                        </div>
                        <div class="feature-item">
                            <div class="feature-icon">🔒</div>
                            <div class="feature-text">安全可靠</div>
                        </div>
                    </div>
                </div>
                <div class="footer-info">
                    <span>Powered By</span>
                    <a href="https://gitee.com/nickbai/sparkshop" target="_blank">
                        {$title} {$version}
                    </a>
                </div>
            </div>
            <div class="login-right">
                <div class="login-form-container">
                    <div class="form-header">
                        <h1>欢迎回来</h1>
                        <p>请登录您的管理员账户</p>
                    </div>
                    <el-form ref="loginForm" :model="form" label-width="0" size="large" class="modern-form">
                        <el-form-item prop="user">
                            <el-input
                                    v-model="form.name"
                                    prefix-icon="el-icon-user"
                                    clearable
                                    placeholder="请输入用户名"
                                    class="modern-input">
                            </el-input>
                        </el-form-item>
                        <el-form-item prop="password">
                            <el-input
                                    v-model="form.password"
                                    prefix-icon="el-icon-lock"
                                    clearable
                                    show-password
                                    placeholder="请输入密码"
                                    class="modern-input">
                            </el-input>
                        </el-form-item>
                        <el-form-item>
                            <div class="captcha-container">
                                <el-input
                                        v-model="form.code"
                                        clearable
                                        placeholder="验证码"
                                        class="modern-input captcha-input">
                                </el-input>
                                <div class="captcha-image" @click="refresh">
                                    <img :src="captchaSrc" alt="验证码">
                                    <span class="refresh-hint">点击刷新</span>
                                </div>
                            </div>
                        </el-form-item>
                        <el-form-item>
                            <el-button
                                    type="primary"
                                    :loading="islogin"
                                    @click="submit"
                                    class="login-btn">
                                <span v-if="!islogin">登录</span>
                                <span v-else>登录中...</span>
                            </el-button>
                        </el-form-item>
                    </el-form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    new Vue({
        el: '#app',
        data: function() {
            return {
                baseIndex: '/{:config("shop.backend_index")}/',
                form: {
                    name: '',
                    password: '',
                    code: ''
                },
                captchaSrc: "{:url('login/captcha')}",
                baseUrl:  "{:url('login/captcha')}",
                islogin: false
            }
        },
        mounted() {
            document.onkeydown = (event) => {
                var e = event || window.event;
                if (e && e.keyCode == 13) {
                    this.submit();
                }
            }
        },
        methods: {
            async submit() {
                if (this.form.name == '') {
                    this.$message.error('请输入用户名');
                    return false;
                }

                if (this.form.password == '') {
                    this.$message.error('请输入密码');
                    return false;
                }

                if (this.form.code == '') {
                    this.$message.error('请输入验证码');
                    return false;
                }

                this.islogin = true
                let res = await request.post(this.baseIndex + "login/doLogin", this.form)
                this.islogin = false
                if (res.code == 0) {
                    this.$message.success('登录成功')
                    setTimeout(function () {
                        window.location.href = '/{:config("shop.backend_index")}';
                    }, 800)
                } else {
                    this.refresh()
                    this.$message.error(res.msg)
                }
            },
            refresh() {
                this.captchaSrc = this.baseUrl + '&t=' + Math.random()
            }
        }
    })
</script>
<style>
    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    html, body, #app {
        height: 100%;
        width: 100%;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    }

    .login-container {
        height: 100vh;
        width: 100vw;
        background: linear-gradient(135deg, #1E9FFF 0%, #0077cc 100%);
        position: relative;
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .particles-bg {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-image:
                radial-gradient(circle at 25% 25%, rgba(255,255,255,0.1) 0%, transparent 50%),
                radial-gradient(circle at 75% 75%, rgba(255,255,255,0.05) 0%, transparent 50%);
        animation: float 20s ease-in-out infinite;
    }

    @keyframes float {
        0%, 100% { transform: translateY(0px) rotate(0deg); }
        50% { transform: translateY(-20px) rotate(180deg); }
    }

    .login-box {
        width: 90%;
        max-width: 1200px;
        height: 600px;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        border-radius: 20px;
        box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
        display: flex;
        overflow: hidden;
        position: relative;
        z-index: 2;
    }

    .login-left {
        flex: 1;
        background: linear-gradient(135deg, #1E9FFF 0%, #0077cc 100%);
        padding: 60px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        color: white;
        position: relative;
        overflow: hidden;
    }

    .login-left::before {
        content: '';
        position: absolute;
        top: -50%;
        right: -50%;
        width: 200%;
        height: 200%;
        background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
        animation: rotate 30s linear infinite;
    }

    @keyframes rotate {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }

    .brand-section {
        position: relative;
        z-index: 2;
    }

    .logo-container {
        margin-bottom: 60px;
    }

    .logo-text {
        font-size: 48px;
        font-weight: 700;
        margin-bottom: 10px;
        background: linear-gradient(45deg, #fff, #f0f0f0);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }

    .logo-subtitle {
        font-size: 18px;
        opacity: 0.9;
        font-weight: 300;
    }

    .feature-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 30px;
        margin-top: 40px;
    }

    .feature-item {
        display: flex;
        align-items: center;
        gap: 15px;
        padding: 20px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 15px;
        backdrop-filter: blur(5px);
        transition: all 0.3s ease;
    }

    .feature-item:hover {
        background: rgba(255, 255, 255, 0.2);
        transform: translateY(-5px);
    }

    .feature-icon {
        font-size: 24px;
    }

    .feature-text {
        font-size: 16px;
        font-weight: 500;
    }

    .footer-info {
        position: relative;
        z-index: 2;
        font-size: 14px;
        opacity: 0.8;
    }

    .footer-info a {
        color: #fff;
        text-decoration: none;
        font-weight: 500;
        margin-left: 8px;
        transition: opacity 0.3s ease;
    }

    .footer-info a:hover {
        opacity: 0.8;
    }

    .login-right {
        flex: 1;
        padding: 60px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .login-form-container {
        width: 100%;
        max-width: 400px;
    }

    .form-header {
        text-align: center;
        margin-bottom: 40px;
    }

    .form-header h1 {
        font-size: 32px;
        color: #2d3748;
        margin-bottom: 10px;
        font-weight: 700;
    }

    .form-header p {
        color: #718096;
        font-size: 16px;
    }

    .modern-form .el-form-item {
        margin-bottom: 25px;
    }

    .modern-input .el-input__inner {
        height: 50px;
        border-radius: 10px;
        border: 2px solid #e2e8f0;
        font-size: 16px;
        transition: all 0.3s ease;
        padding-left: 45px;
    }

    .modern-input .el-input__inner:focus {
        border-color: #1E9FFF;
        box-shadow: 0 0 0 3px rgba(30, 159, 255, 0.1);
    }

    .modern-input .el-input__prefix {
        left: 15px;
    }

    .modern-input .el-input__prefix .el-input__icon {
        font-size: 18px;
        color: #718096;
    }

    .captcha-container {
        display: flex;
        gap: 15px;
        align-items: center;
    }

    .captcha-input {
        flex: 1;
    }

    .captcha-image {
        position: relative;
        cursor: pointer;
        border-radius: 8px;
        overflow: hidden;
        border: 2px solid #e2e8f0;
        transition: all 0.3s ease;
        width: 180px;
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .captcha-image:hover {
        border-color: #1E9FFF;
        transform: scale(1.05);
    }

    .captcha-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .refresh-hint {
        position: absolute;
        bottom: -25px;
        left: 50%;
        transform: translateX(-50%);
        font-size: 12px;
        color: #718096;
        white-space: nowrap;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .captcha-image:hover .refresh-hint {
        opacity: 1;
    }

    .login-btn {
        width: 100%;
        height: 50px;
        border-radius: 10px;
        font-size: 16px;
        font-weight: 600;
        background: linear-gradient(135deg, #1E9FFF 0%, #0077cc 100%);
        border: none;
        transition: all 0.3s ease;
        position: relative;
        overflow: hidden;
    }

    .login-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 25px rgba(30, 159, 255, 0.3);
    }

    .login-btn:active {
        transform: translateY(0);
    }

    .login-btn.is-loading {
        background: #cbd5e0;
    }

    @media (max-width: 768px) {
        .login-box {
            flex-direction: column;
            height: auto;
            max-width: 400px;
        }

        .login-left {
            padding: 40px;
        }

        .login-right {
            padding: 40px;
        }

        .logo-text {
            font-size: 36px;
        }

        .feature-grid {
            grid-template-columns: 1fr;
            gap: 20px;
        }

        .captcha-container {
            flex-direction: column;
            gap: 10px;
        }

        .captcha-image {
            width: 100%;
            height: 50px;
        }
    }
</style>
</body>
</html>